package com.luyuan.crm.question.web;

import javax.annotation.Resource;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.luyuan.crm.question.model.QuestionExtendField;
import com.luyuan.crm.question.model.QuestionExtend;
import com.luyuan.crm.question.service.QuestionExtendFieldService;
import com.luyuan.crm.question.service.QuestionExtendService;
import com.ruijie.web.jsf.action.BaseAction;

@Component("addQuestionExtendFieldAction")
@Scope("view")
public class AddQuestionExtendFieldAction extends BaseAction implements
		InitializingBean {

	private QuestionExtend questionExtend;

	private QuestionExtendField questionExtendField = new QuestionExtendField();

	@Resource(name = "questionExtendService")
	private QuestionExtendService questionExtendService;

	@Resource(name = "questionExtendFieldService")
	private QuestionExtendFieldService questionExtendFieldService;

	public void addQuestionExtendField() {
		questionExtendField.setQuestionExtend(questionExtend);
		questionExtendFieldService.save(questionExtendField);
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		String id = getRequestParameter("uuid");
		questionExtend = questionExtendService.getById(Integer.parseInt(id));
	}

	public QuestionExtend getQuestionExtend() {
		return questionExtend;
	}

	public void setQuestionExtend(QuestionExtend questionExtend) {
		this.questionExtend = questionExtend;
	}

	public QuestionExtendField getQuestionExtendField() {
		return questionExtendField;
	}

	public void setQuestionExtendField(QuestionExtendField questionExtendField) {
		this.questionExtendField = questionExtendField;
	}

}
